﻿using System;
using System.Linq;
using System.Windows.Forms;

namespace Project.Co_DataTransformationPrototype.UI
{
    public partial class SelectEntityDialogBox : Form
    {
        private EntityShape[] entityArray;
        public Entity targetEntity;

        public SelectEntityDialogBox(EntityShape[] entityArray)
        {
            this.entityArray = entityArray;
            InitializeComponent();
        }

        private void SelectEntityDialogBox_Load(object sender, EventArgs e)
        {
            cboEntities.Items.AddRange(entityArray.OrderBy(ent => (ent.ModelElement as Entity).CurrentName).ToArray());
        }

        private void btnSelect_Click(object sender, EventArgs e)
        {
            if (cboEntities.SelectedItem != null)
            {
                targetEntity = (cboEntities.SelectedItem as EntityShape).ModelElement as Entity;
                this.DialogResult = System.Windows.Forms.DialogResult.OK;
            }
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

    }
}
